//Map类
class Mapp{
    constructor(option){
        this.dom = createImg()
        this.top = option.top
        this.speed = option.speed
        this.dom.src  = option.resource
    }
    patch(){
        render(this.dom,this.top,0)
    }
    move(){
        this.top += this.speed
    }
}


//新建2个img元素， 渲染到界面
    //创建
const map1 = new Mapp({top:0,speed:5,resource:'./assets/map.jpg'})
const map2 = new Mapp({top:-1080,speed:5,resource:'./assets/map.jpg'})

    //渲染style属性     注：src不能被当做参数传入
map1.patch()
map2.patch()

    //追加到页面
app.appendChild(map1.dom)
app.appendChild(map2.dom)




//定时改变元素的top值，重新渲染

setInterval(()=>{
    //改变top值
    map1.move()
    map2.move()
    if(map1.top >= 1080){
        map1.top = -1080
    }
    if(map2.top >= 1080){
        map2.top = -1080
    }
    //渲染
    map1.patch()
    map2.patch()
}, 10)